<?php

// $Id$

require_once(TANGRA_MAIN_DIR.'form/guardable_form.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/text/form_field_text.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/hidden/form_field_hidden.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/integer_limited/form_field_integer_limited.class.php');
require_once(TANGRA_MAIN_DIR.'/form/static_html_form_generator.class.php');


class Category_Form extends Guardable_Form {
	function __construct() {
		parent::__construct('category', 'admin/modules/tangra_cms/category/category_edit.php');

		$f_title = new Form_Field_Text('title', true, 255);
		$this->add_field($f_title);

		$f_parent = new Form_Field_Hidden('parent', 0, true);
		$this->add_field($f_parent);


		$f_hid = new Form_Field_Text('hid', true, 100);
		$f_hid->add_potential_error('invalid_hid');
		$f_hid->add_potential_error('not_unique');
		$this->add_field($f_hid);

		$f_ordering = new Form_Field_Integer_Limited('ordering', 0, 1000, false, 4, 10);
		$this->add_field($f_ordering);
	}


	public function generate_html() {
		$html_gen = new Static_HTML_Form_Generator($this, 'modules/form_html_tpl_static_ajax_metallic_en', 'en');
		$html_gen->create_default_tpl_maps();
		$html_gen->change_field_p_error_map_entry('hid', 'invalid_hid', 'modules/tangra_cms/forms/en/category/field_error_invalid_hid.tpl');
		$html_gen->change_field_p_error_map_entry('hid', 'not_unique', 'modules/tangra_cms/forms/en/category/field_error_not_unique.tpl');

		printbr('<pre>');
		printbr(htmlentities($html_gen->get_static_html()));
		printbr('</pre>');
	}
}
